using System;
using System.Collections.Generic;
using System.IO;

namespace Update.Utils.Interfaces
{
    /// <summary>
    /// 文件操作帮助类接口
    /// </summary>
    public interface IFileHelper
    {
        /// <summary>
        /// 检查文件是否被占用
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <returns>是否被占用</returns>
        bool IsFileInUse(string filePath);

        /// <summary>
        /// 尝试结束占用文件的进程
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <param name="processName">进程名，如果为null则自动检测</param>
        /// <param name="logger">日志记录回调</param>
        /// <returns>是否成功结束进程</returns>
        bool TerminateProcessesUsingFile(string filePath, string processName, Action<string> logger = null);

        /// <summary>
        /// 创建目录（如果不存在）
        /// </summary>
        /// <param name="directoryPath">目录路径</param>
        void CreateDirectoryIfNotExists(string directoryPath);

        /// <summary>
        /// 安全删除文件
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <returns>是否成功删除</returns>
        bool SafeDeleteFile(string filePath);

        /// <summary>
        /// 获取临时目录路径
        /// </summary>
        /// <param name="subDir">子目录名称</param>
        /// <returns>临时目录完整路径</returns>
        string GetTempDirectory(string subDir = "AppUpdater");

        /// <summary>
        /// 提取更新包
        /// </summary>
        /// <param name="zipPath">更新包路径</param>
        /// <param name="targetDir">目标目录</param>
        /// <param name="forceOverwrite">是否强制覆盖</param>
        /// <param name="autoTerminateProcesses">是否自动结束占用进程</param>
        /// <param name="targetAppExe">目标应用程序文件名</param>
        /// <param name="logger">日志记录回调</param>
        /// <returns>操作结果和跳过的文件列表</returns>
        (bool Success, List<string> SkippedFiles) ExtractUpdatePackage(
            string zipPath, 
            string targetDir, 
            bool forceOverwrite, 
            bool autoTerminateProcesses, 
            string targetAppExe,
            Action<string> logger = null);
    }
} 